Extract shared frame-exit result construction#1578
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extracts the common “frame exit” logic (gas-left/gas-refund/output handling) into a shared helper so both Baseline and Advanced interpreters construct evmc_result consistently.
Changes:
- Added
make_execution_result()helper inexecution_state.hppto centralize frame-exit result construction. - Updated Baseline interpreter to use the shared helper instead of duplicating result-building logic.
- Updated Advanced interpreter to use the shared helper instead of duplicating result-building logic.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/evmone/execution_state.hpp | Introduces shared helper for building evmc_result from final frame state and remaining gas. |
| lib/evmone/baseline_execution.cpp | Switches Baseline execution to use the shared result-construction helper. |
| lib/evmone/advanced_execution.cpp | Switches Advanced execution to use the shared result-construction helper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+203
to
+211
| inline evmc_result make_execution_result(ExecutionState& state, int64_t gas) noexcept | ||
| { | ||
| const auto gas_left = (state.status == EVMC_SUCCESS || state.status == EVMC_REVERT) ? gas : 0; | ||
| const auto gas_refund = (state.status == EVMC_SUCCESS) ? state.gas_refund : 0; | ||
|
|
||
| assert(state.output_size != 0 || state.output_offset == 0); | ||
| return evmc::make_result(state.status, gas_left, gas_refund, | ||
| state.output_size != 0 ? &state.memory[state.output_offset] : nullptr, state.output_size); | ||
| } |
Use shared procedure for frame exit in Baseline and Advanced.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1578 +/- ##
==========================================
- Coverage 97.41% 97.41% -0.01%
==========================================
Files 163 163
Lines 14680 14677 -3
Branches 3407 3404 -3
==========================================
- Hits 14300 14297 -3
Misses 280 280
Partials 100 100
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use shared procedure for frame exit in Baseline and Advanced.